// 引入路由
import { constantRoute } from '@/router/routes'
// 创建用户相关的仓库
import { defineStore } from 'pinia'
const userStore = defineStore('user', {
  state: () => {
    return {
      token: localStorage.getItem('TOKEN'),
      userInfo: localStorage.getItem('USERINFO'),
      menuRoutes: constantRoute,
    
    }
  },
  actions: {
    // 用户登陆方法
    userLogin(token: any) {
      console.log(token)
      userStore().token = token
      localStorage.setItem('TOKEN', token)
    },
    saveUserInfo(Info: any) {
      console.log(Info)
      // userStore().userInfo = Info
      console.log(JSON.stringify(Info));
      userStore().userInfo = JSON.stringify(Info)
      localStorage.setItem('USERINFO',JSON.stringify(Info))
    },
  },
  getters: {},
})
// 对外暴露
export default userStore
